#!/usr/bin/env python

# -*- coding: utf-8 -*-
 
import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtDeclarative import *

from Controller import Controller

class MainWindow( QDeclarativeView ):
    
    def __init__( self, parent = None ):
        super( MainWindow, self ).__init__( parent )
        self.setWindowTitle( "Same" )
        # Renders 'samegame.qml'
        url = QUrl( './qml/samegame.qml' )
        self.setSource( url )
        # QML resizes to main window
        self.setResizeMode( QDeclarativeView.SizeRootObjectToView )
        
        ctrl = Controller( rootView = self )
        self.rootContext().setContextProperty( 'controller', ctrl );


def main():
    # Create Qt application and the MainWindow
    app = QApplication( sys.argv )
    
    view = MainWindow()
    view.show()

    # Enter Qt main loop
    sys.exit( app.exec_() )

if __name__ == "__main__":
    main()